<template>
  <input type="number" v-model="n1">
  <select name="fuhao" id="" v-model="fuhao">
    <option value="+">+</option>
    <option value="-">-</option>
    <option value="*">*</option>
    <option value="/">/</option>
  </select>
  <input type="text" v-model="n2">
  <button @click="f">=</button>
  <span>{{result}}</span>
</template>

<script lang="ts" setup>
import {ref} from "vue";

const n1=ref()
const n2=ref()
const fuhao=ref("+")
const result=ref()
function f(){
  switch(fuhao.value){
    case "+":
      result.value=parseInt(n1.value)+parseInt(n2.value)
      break;
    case "-":
      result.value=n1.value-n2.value
      break;
    case "*":
      result.value=n1.value*n2.value
      break;
    case "/":
      if (n2.value==0){
        alert("除数不能为0")
        return
      }
      result.value=n1.value/n2.value
      break;
  }
}
</script>


<style>

</style>